{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 向量化函数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "自定义的 `sinc` 函数："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "def sinc(x):\n",
    "    if x == 0.0:\n",
    "        return 1.0\n",
    "    else:\n",
    "        w = np.pi * x\n",
    "        return np.sin(w) / w"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "作用于单个数值："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sinc(0.0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.8981718325193755e-17"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sinc(3.0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "但这个函数不能作用于数组："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-4-9d4f36f2aa7a>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0mx\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0msinc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32m<ipython-input-1-dffe464e3332>\u001b[0m in \u001b[0;36msinc\u001b[1;34m(x)\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0msinc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m     \u001b[1;32mif\u001b[0m \u001b[0mx\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;36m0.0\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      5\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[1;36m1.0\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m     \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mValueError\u001b[0m: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"
     ]
    }
   ],
   "source": [
    "x = np.array([1,2,3])\n",
    "sinc(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "可以使用 `numpy` 的 `vectorize` 将函数 `sinc` 向量化，产生一个新的函数："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([  3.89817183e-17,  -3.89817183e-17,   3.89817183e-17])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vsinc = np.vectorize(sinc)\n",
    "vsinc(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "其作用是为 `x` 中的每一个值调用 `sinc` 函数："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0xa24e4e0>]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAEACAYAAAC9Gb03AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmYVNWZx/HvK4iKG6IRVEBEoQUUFwxxSUy5hnHNTBId\nR4lxmRAUNY4muGS0jUviGowatxFikploXJJRx11pExU3VmVHUEBBkcWIYlj6nT9OtbZt7/fWvbdu\n/T7Pw2NV16lz3rK73jp1tmvujoiI5NcGaQcgIiKlpUQvIpJzSvQiIjmnRC8iknNK9CIiOadELyKS\nc5ETvZmNMbP3zOz1Jh4/0cymmNlUM3vBzAZFbVNERFovjh79WGBoM4/PAw5090HA5cAdMbQpIiKt\nFDnRu/vfgBXNPD7e3T8s3n0Z6BG1TRERab2kx+hPAx5NuE0RkYrWMamGzOwg4FTggKTaFBGRhBJ9\ncQL2TmCouzc6zGNmOnRHRKQd3N2ae7zkQzdm1gt4EDjJ3ec2V9bdc/vv0ksvTT0GvTa9Pr2+/P1r\njcg9ejP7I/BNYBszWwhcCmxYTNy3A5c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+YVPls5To+wIHmtlLZlZjZvukHVCczOxYYJG7T007lgScCjyadhAx2AFYWO/+ouLPcsfM\negN7ET6k8yLPmzV3Apaa2Vgzm2hmd5pZ56YKN7thKm4tbMDqCGzl7vua2VeBPwF9kowvqhZe34XA\n4fWLJxJUjJp5fRe5+8PFMhcDa9z9fxINrjTy+HX/S8xsM+B+4Jxiz77sVcBmzY7A3sBId3/VzEYT\nzhu7pKnCiXH3w5p6zMxGAA8Wy71anLDc2t2XJRZgRE29PjPbjfAJPMXMIAxrTDCzIe7+foIhRtLc\n7w/AzH5A+Kp8SCIBld47QM9693sSevW5YWYbAg8Af3D3v6QdT4z2B44xsyMobtY0s981tlmzTC0i\njBC8Wrx/P80cLJmloZu/ENbjY2b9gE7llOSb4+5vuHs3d9/J3Xci/JL2Lqck3xIzG0r4mnysu3+a\ndjwxeQ3oa2a9zawTcDzwUMoxxcZCr+MuYLq7j047nji5+0Xu3rP4fvtX4NkcJXncfQmwsJgrAQ4F\npjVVPtEefQvGAGPM7HVgDZCbX0oj8jgkcBPQCXiq+K1lvLufkW5I0bj7OjMbCTwBdADucvcmVzaU\noQOAk4CpZjap+LML3f3xFGMqlTy+584C/rvYCXkTOKWpgtowJSKSc1kauhERkRJQohcRyTklehGR\nnFOiFxHJOSV6EZGcU6IXEck5JXoRkZxTohcRybn/B44x+J9qVCmGAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xa0b3ac8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "\n",
    "x = np.linspace(-5,5,101)\n",
    "plt.plot(x, vsinc(x))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "因为这样的用法涉及大量的函数调用，因此，向量化函数的效率并不高。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
